package com.lanyou.cook.util;

import java.util.Date;

import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.LazyDynaBean;

public class DateUtil {

	public static DynaBean fixBeginTimeAndEndTime(Date beginTime, Date endTime) {
		if (beginTime == null) {
			beginTime = new Date(0);
		}

		if (endTime == null) {
			endTime = new Date();
		}

		if (beginTime.equals(endTime) || beginTime.after(endTime)) {
			endTime = new Date();
		}

		DynaBean result = new LazyDynaBean();
		result.set("begin", beginTime);
		result.set("end", endTime);
		return result;
	}
}
